package com.tech.pattern.iterator;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.function.Consumer;

/**
 * @Description:
 * @Author: zl
 * @Date: 2019/7/12 14:26
 */

public class ConcreteIterator implements Iterator {
    private List list = new ArrayList();
    private int cursor = 0;

    public ConcreteIterator(List list) {
        this.list = list;
    }

    @Override
    public boolean hasNext() {
        if (cursor == list.size()) {
            return false;
        }
        return true;
    }

    @Override
    public Object next() {
        Object object = null;
        if (this.hasNext()) {
            object = this.list.get(cursor++);
        }
        return object;
    }
}
